package com.bright.hxj.qchz.service.mq;

import com.bright.hxj.qchz.pojo.bo.DuijieReturnMsg;
import com.bright.hxj.qchz.pojo.command.SubmitTaskCommand;
import com.bright.hxj.qchz.pojo.po.TaskAsync;
import com.bright.hxj.qchz.service.AbstractSubmitTaskService;
import com.bright.hxj.qchz.service.TaskAsyncService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

/**
 * @Author hxj
 * @Date 2025/1/7 11:50
 * @Description 消息队列生产者方法
 */
@Component
@RequiredArgsConstructor
//@ConditionalOnBean(value = RocketMQTemplate.class)
@ConditionalOnProperty(name = "submit-task.type", havingValue = "rocketMQ")
@Slf4j
public class RocketMQSubmitTaskServiceImpl extends AbstractSubmitTaskService {

    private final RocketMQTemplate rocketMQTemplate;
    private final TaskAsyncService taskAsyncService;

    @Override
    protected DuijieReturnMsg submitTask(SubmitTaskCommand command, TaskAsync taskAsync) {



        rocketMQTemplate.convertAndSend(RocketMQConstant.TOPIC_CONSUMER, taskAsync);
        return new DuijieReturnMsg(true, null);
    }
}
